package ogdkp.command;

import java.util.List;

import ogdkp.View;
import ogdkp.dialog.SetRaidersDialog;
import ogdkp.om.Player;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.PlatformUI;

public class SetRaidersCommand extends AbstractHandler {

	@Override
	public Object execute(final ExecutionEvent event) throws ExecutionException {
		final View view =
		        (View) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("OGDKP.view");
		final List<Player> players = view.getModel();
		final SetRaidersDialog dialog = new SetRaidersDialog(view.getSite().getShell());
		dialog.setPlayers(view.getModel());
		if (dialog.open() == dialog.OK) {
			view.refresh();
		}
		return null;
	}

}
